package com.cac.demo.controller.msWorkbinMaterial;/*
 *@program:test-curd
 *@description:缓存箱物料信息服务接口
 *@author: lsl
 *@Time: 2022/9/5  10:38
 */

import com.alibaba.fastjson.JSON;
import com.cac.demo.entity.msWorkbinMaterial.MsWorkbinMaterialDTO;
import com.cac.demo.service.materialScan.WmsDeliverPlanService;
import com.cac.demo.service.msWorkbinMaterial.MsWorkbinMaterialService;


import com.cac.demo.util.adapter.PageParameter;
import com.cac.demo.util.adapter.QueryReqBean;
import com.cac.demo.util.adapter.QueryRespBean;
import com.cac.demo.util.adapter.ResponseMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/MsWorkbinMaterial")
public class MsWorkbinMaterialRest {

    @Autowired
    private MsWorkbinMaterialService msWorkbinMaterialService;

    @Autowired
    private WmsDeliverPlanService wmsDeliverPlanService;

    //根据工作包编码查询缓存箱物料信息
    @PostMapping("/searchWorkBinByPackage")
    public ResponseMsg<QueryRespBean<MsWorkbinMaterialDTO>> searchByPackage(@RequestBody Map map) {
        ResponseMsg<QueryRespBean<MsWorkbinMaterialDTO>> responseMsg = new ResponseMsg<>();
        String aoBarcode= (String) map.get("aoBarcode");
        String page = JSON.toJSONString(map.get("pageParameter"));
        PageParameter pageParameter = JSON.parseObject(page, PageParameter.class);
        String DTO = JSON.toJSONString(map.get("searchParams"));
        MsWorkbinMaterialDTO searchParams = JSON.parseObject(DTO,MsWorkbinMaterialDTO.class);
        QueryReqBean<MsWorkbinMaterialDTO> queryReqBean = new QueryReqBean<>();
        queryReqBean.setPageParameter(pageParameter);
        queryReqBean.setSearchParams(searchParams);
        QueryRespBean<MsWorkbinMaterialDTO> result = msWorkbinMaterialService.searchByPackage(queryReqBean,aoBarcode);
        responseMsg.setResponseBody(result);
        return responseMsg;
    }
}
